package com.rd.student.jike.class2.lihongming.Solution713;

import java.util.Scanner;

/**
 * @Auther:Heinrich
 * @Date:2023/7/13-07-13-10:56
 * @Description:com.rd.student.jike.class2.lihongming.Solution713
 * @version:1.0
 */
public class Question12 {

    static Integer itar = 0;
    public static void main(String[] args) {
        Chessboard chessboard = new Chessboard();
        Scanner sc = new Scanner(System.in);

        while (true){
            chessboard.playChess(sc.nextInt(), sc.nextInt());
        }
    }

}
class Chessboard{
    int[][] chess = new int[15][15];
    public void playChess(int x,int y){

        if(this.chess[x][y]!=0){
            System.out.println("落子处有子，错误，重新落子");
        }
        else{
            this.chess[x][y]=(int)Math.pow(-1,Question12.itar);
            Question12.itar++;
        }

        for (int i = 0; i < chess.length; i++) {
            for (int j = 0; j < chess.length; j++) {
                System.out.print(this.chess[i][j]+"\t");
            }
            System.out.println();
        }
        if (winChess(this.chess)) {
            System.out.println("Game Win!");
            System.exit(0);
        }
    }
    public boolean winChess(int[][] chess){
        for (int i = 0; i < chess.length; i++) {
            int count =0 ;
            for (int j = 0; j < chess.length; j++) {
                if(i<14&&j<14&&chess[i][j]==1&&chess[i][j]==chess[i][j+1]){
                    count++;
                    if(count==4)return true;
                }else {
                    count=0;
                }
            }
        }
        for (int i = 0; i < chess.length; i++) {
            int count =0 ;
            for (int j = 0; j < chess.length; j++) {
                if(i<14&&j<14&&chess[i][j]==-1&&chess[i][j]==chess[i][j+1]){
                    count++;
                    if(count==4)return true;
                }else {
                    count=0;
                }
            }
        }
        for (int j = 0; j < chess.length; j++) {
            int count =0 ;
            for (int i = 0; i < chess.length; i++) {
                if(i<14&&j<14&&chess[i][j]==1&&chess[i][j]==chess[i][j+1]){
                    count++;
                    if(count==4)return true;
                }else {
                    count=0;
                }
            }

        }
        for (int j = 0; j < chess.length; j++) {
            int count =0 ;
            for (int i = 0; i < chess.length; i++) {
                if(i<14&&j<14&&chess[i][j]==-1&&chess[i][j]==chess[i][j+1]){
                    count++;
                    if(count==4)return true;
                }else {
                    count=0;
                }
            }

        }

        for (int i = 0; i < chess.length; i++) {
            int count =0 ;
            for (int j = 0; j < chess.length; j++) {
                int q = i ,p = j;
                for (int k = 0; k < 5; k++) {
                    if(q<14&&p<14&&chess[q][p]==chess[q++][p++]&&chess[p][q]==1){
                        count++;
                        if(count==4){
                            return true;
                        }
                    }else{
                        count=0;
                    }
                }
            }
        }
        for (int i = 0; i < chess.length; i++) {
            int count =0 ;
            for (int j = 0; j < chess.length; j++) {
                int q = i ,p = j;
                for (int k = 0; k < 5; k++) {
                    if(q<14&&p<14&&chess[q][p]==chess[q++][p++]&&chess[p][q]==-1){
                        count++;
                        if(count==4){
                            return true;
                        }
                    }else{
                        count=0;
                    }
                }
            }
        }
        for (int i = 0; i < chess.length; i++) {
            int count =0 ;
            for (int j = 0; j < chess.length; j++) {
                int q = i ,p = j;
                for (int k = 0; k < 5; k++) {
                    if(q>0&&p<14&&chess[q][p]==chess[q--][p++]&&chess[p][q]==1){
                        count++;
                        if(count==5){
                            return true;
                        }
                    }else{
                        count=0;
                    }
                }
            }
        }
        for (int i = 0; i < chess.length; i++) {
            int count =0 ;
            for (int j = 0; j < chess.length; j++) {
                int q = i ,p = j;
                for (int k = 0; k < 5; k++) {
                    if(q>0&&p<14&&chess[q][p]==chess[q--][p++]&&chess[p][q]==-1){
                        count++;
                        if(count==5){
                            return true;
                        }
                    }else{
                        count=0;
                    }
                }
            }
        }
        return false;
    }
}